﻿<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="generator" content="Jekyll v3.6.0">
<title>文件选择 &middot; BootstrapVue</title>
<!-- Bootstrap 核心CSS -->
<link href="../../../v4/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- 本文档额外专用css -->
<link href="../../../v4/assets/css/docsearch.min.css" rel="stylesheet">
<link href="../../../v4/assets/css/docs.min.css" rel="stylesheet">
<link href="../../style/bv_path.css" rel="stylesheet">

<!-- Favicons图标定义 -->
<link data-n-head="ssr" rel="manifest" href="../../manifest.json">
<link data-n-head="ssr" rel="shortcut icon" href="../../style/icons/icon_64.png">
<link data-n-head="ssr" rel="apple-touch-icon" href="../../style/icons/icon_512.png" sizes="512x512">

<!-- Meta关键字定义 -->
<meta name="description" content="The most popular HTML, CSS, and JS library in the world.">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">

</head>
<body>
<a id="skippy" class="sr-only sr-only-focusable" href="#content">
<div class="container"> <span class="skiplink-text">跳到主体内容</span> </div>
</a>
<header class="navbar navbar-expand navbar-dark flex-column flex-md-row bd-navbar"> <a class="navbar-brand mr-0 mr-md-2" href="../" aria-label="Bootstrap">
  <svg class="d-block" width="36" height="36" viewbox="0 0 612 612" xmlns="http://www.w3.org/2000/svg" focusable="false">
    <title>Bootstrap</title>
    <path fill="currentColor" d="M510 8a94.3 94.3 0 0 1 94 94v408a94.3 94.3 0 0 1-94 94H102a94.3 94.3 0 0 1-94-94V102a94.3 94.3 0 0 1 94-94h408m0-8H102C45.9 0 0 45.9 0 102v408c0 56.1 45.9 102 102 102h408c56.1 0 102-45.9 102-102V102C612 45.9 566.1 0 510 0z"/>
    <path fill="currentColor" d="M196.77 471.5V154.43h124.15c54.27 0 91 31.64 91 79.1 0 33-24.17 63.72-54.71 69.21v1.76c43.07 5.49 70.75 35.82 70.75 78 0 55.81-40 89-107.45 89zm39.55-180.4h63.28c46.8 0 72.29-18.68 72.29-53 0-31.42-21.53-48.78-60-48.78h-75.57zm78.22 145.46c47.68 0 72.73-19.34 72.73-56s-25.93-55.37-76.46-55.37h-74.49v111.4z"/>
  </svg>
  </a>
  <div class="navbar-nav-scroll">
    <ul class="navbar-nav bd-navbar-nav flex-row">
      <li class="nav-item"><a class="nav-link " href="../">首页</a></li>
      <li class="nav-item"><a class="nav-link" href="index.html">中文手册</a></li>
      <li class="nav-item"><a class="nav-link active" href="../components">组件</a></li>
      <li class="nav-item"><a class="nav-link " href="../directives">指令</a></li>
      <li class="nav-item"><a class="nav-link " href="../reference">参考</a></li>
      <li class="nav-item"><a class="nav-link " href="https://bootstrap-vue.org/play" target="_blank">体验</a></li>
      <li class="nav-item"><a class="nav-link " href="http://code.z01.com/v4"><i class="zi zi_bold" zico="粗"></i> Boostrap</a></li>
      <li class="nav-item"><a class="nav-link" href="http://ico.z01.com" target="_blank" rel="noopener">zico图标系统</a></li>
      <li class="nav-item"><a class="nav-link" href="http://www.z01.com" target="_blank" rel="noopener">Zoomla!逐浪CMS</a></li>
    </ul>
  </div>
  <ul class="navbar-nav flex-row ml-md-auto d-none d-md-flex">
    <li class="nav-item dropdown"> <a class="nav-item nav-link dropdown-toggle mr-md-2" href="#" id="bd-versions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="alse"> v2.12.0 </a>
      <div class="dropdown-menu dropdown-menu-right" aria-labelledby="bd-versions"> 
        <a class="dropdown-item active" href="../../../bootstrap-vue/docs/4.0/">Latest (4.3.x)</a>
        <a class="dropdown-item" href="/Boot/">v3.3.7</a>
        <a class="dropdown-item" href="/Sass/">Sass语言</a>
        <a class="dropdown-item" href="/Emmet/">Emmet语法</a>
        <a class="dropdown-item" href="//www.z01.com/tool/" target="_blank">IIS站长工具</a>
        <a class="dropdown-item" href="//ad.z01.com/" target="_blank">广告源码</a>
        <a class="dropdown-item" href="//v.z01.com/mb/" target="_blank">免费模板</a>
        <a class="dropdown-item" href="//v.z01.com/" target="_blank">H5移动创作</a>
        <a class="dropdown-item" href="//www.z01.com/help/web/3234.shtml" target="_blank">Flexbox布局</a>
		<a class="dropdown-item" href="/boot/font.html" target="_blank">Font Awesome</a>
</div>
    </li>
    <li class="nav-item"> <a class="nav-link p-2" href="//zoomla.github.io/bootstrap4-zhcn-documentation" target="_blank" rel="noopener" aria-label="GitHub">
      <svg class="navbar-nav-svg" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 512 499.36" focusable="false">
        <title>GitHub</title>
        <path d="M256 0C114.64 0 0 114.61 0 256c0 113.09 73.34 209 175.08 242.9 12.8 2.35 17.47-5.56 17.47-12.34 0-6.08-.22-22.18-.35-43.54-71.2 15.49-86.2-34.34-86.2-34.34-11.64-29.57-28.42-37.45-28.42-37.45-23.27-15.84 1.73-15.55 1.73-15.55 25.69 1.81 39.21 26.38 39.21 26.38 22.84 39.12 59.92 27.82 74.5 21.27 2.33-16.54 8.94-27.82 16.25-34.22-56.84-6.43-116.6-28.43-116.6-126.49 0-27.95 10-50.8 26.35-68.69-2.63-6.48-11.42-32.5 2.51-67.75 0 0 21.49-6.88 70.4 26.24a242.65 242.65 0 0 1 128.18 0c48.87-33.13 70.33-26.24 70.33-26.24 14 35.25 5.18 61.27 2.55 67.75 16.41 17.9 26.31 40.75 26.31 68.69 0 98.35-59.85 120-116.88 126.32 9.19 7.9 17.38 23.53 17.38 47.41 0 34.22-.31 61.83-.31 70.23 0 6.85 4.61 14.81 17.6 12.31C438.72 464.97 512 369.08 512 256.02 512 114.62 397.37 0 256 0z" fill="currentColor" fill-rule="evenodd"/>
      </svg>
      </a> </li>
    <li class="nav-item"> <a class="nav-link p-2" href="http://www.z01.com/blog/ren/3214.shtml" target="_blank" rel="noopener" aria-label="Slack">译者说</a></li>
  </ul>
  <a class="btn btn-bd-yellow d-none d-lg-inline-block mb-3 mb-md-0 ml-md-3" href="download.html">下载 Bootstrap</a> </header>

<div class="container-fluid">
  <div class="row flex-xl-nowrap">
    <div class="col-12 col-md-3 col-xl-2 bd-sidebar">
      <form class="bd-search d-flex align-items-center">
        <input type="search" class="form-control" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off">
        <button class="btn btn-link bd-search-docs-toggle d-md-none p-0 ml-3" type="button" data-toggle="collapse" data-target="#bd-docs-nav" aria-controls="bd-docs-nav" aria-expanded="false" aria-label="Toggle docs navigation">
        <svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 30 30" width="30" height="30" focusable="false">
          <title>Menu</title>
          <path stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="M4 7h22M4 15h22M4 23h22"/>
        </svg>
        </button>
      </form>


<nav class="collapse bd-links" id="bd-docs-nav">
<div class=""><a href="../" class="bd-toc-link">首页</a></div>
<div class="bd-toc-item nuxt-link-exact-active "><a href="../../../bootstrap-vue/docs/" class="bd-toc-link  "> 起步 </a>
<ul class="nav bd-sidenav">
</ul>
</div>
<div class="bd-toc-item active"><a href="../../../bootstrap-vue/docs/components/" class="bd-toc-link nuxt-link-exact-active"> 组件 </a>
<ul class="nav bd-sidenav">
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/index.html" class="nav-link"> 组件目录 </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/alert.html" class="nav-link"> 警告提示框(Alert) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/badge.html" class="nav-link"> 徽章(Badge) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/badge.html" class="nav-link"> 面包屑导航(Breadcrumb) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/button.html" class="nav-link"> 按钮(Button) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/button-group.html" class="nav-link"> 按钮组(Button Group) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/button-toolbar.html" class="nav-link"> 按钮Toolbar(Button Toolbar) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/calendar.html" class="nav-link"> 日历组件(Calendar) <small class="badge text-uppercase badge-success">New</small> </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/card.html" class="nav-link"> 卡片(Card) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/carousel.html" class="nav-link"> 轮播效果(Carousel) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/collapse.html" class="nav-link"> 折叠面板(Collapse) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/dropdown.html" class="nav-link"> 下拉菜单(Dropdown) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/embed.html" class="nav-link"> 嵌入(Embed) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form.html" class="nav-link"> 表单(Form) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form-checkbox.html" class="nav-link"> 表单复选框(Form Checkbox) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form-datepicker.html" class="nav-link"> 表单时间选择器(Form Datepicker) <small class="badge text-uppercase badge-success">New</small> </a></li>
<li class="nav-item active"><a href="../../../bootstrap-vue/docs/components/form-file.html" class="nav-link"> 文件选择(Form File) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form-group.html" class="nav-link"> 表单组合(Form Group) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form-input.html" class="nav-link"> 表单输入框(Form Input) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form-radio.html" class="nav-link"> 单选择表单Form Radio </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form-select.html" class="nav-link"> 下拉式表单(Form Select) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form-spinbutton.html" class="nav-link"> 按钮式表单(Form Spinbuttno) <small class="badge text-uppercase badge-success">New</small> </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form-tags.html" class="nav-link"> Tags表单选择器(Form Tags) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form-textarea.html" class="nav-link"> 文本框(Form Textarea) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/form-timepicker.html" class="nav-link"> 表单内时间控件(Form Timepicker) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/image.html" class="nav-link"> 图片(Image) </a></li>

<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/input-group.html" class="nav-link"> 输入框(Input Group) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/jumbotron.html" class="nav-link"> Hero大块屏(Jumbotron) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/layout.html" class="nav-link"> 布局与网络Layout and Grid System </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/link.html" class="nav-link"> 链接(Link)</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/list-group.html" class="nav-link"> 列表组(List group) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/media.html" class="nav-link"> 媒体(Media) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/modal.html" class="nav-link"> 弹出模态框(Modal) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/nav.html" class="nav-link"> 导航(Nav) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/navbar.html" class="nav-link"> 导航栏(Navbar) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/pagination.html" class="nav-link"> 分页(Pagination) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/pagination-nav.html" class="nav-link"> 分页导航(Pagination Nav) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/popover.html" class="nav-link"> 指示备注(Popover) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/progress.html" class="nav-link"> 进度指示器(Progress) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/spinner.html" class="nav-link"> 旋转指示器(Spinner) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/table.html" class="nav-link"> 表格(Table) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/tabs.html" class="nav-link"> 选项卡(Tabs) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/time.html" class="nav-link"> 时间组件(Time) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/toast.html" class="nav-link"> 冒泡推送(Toasts) </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/components/tooltip.html" class="nav-link"> tip提示组件(Tooltip) </a></li>
</ul>
</div>
<div class="bd-toc-item"><a href="../../../bootstrap-vue/docs/directives/" class="bd-toc-link"> 指令 </a>
<ul class="nav bd-sidenav">
<li class="nav-item"><a href="../../../bootstrap-vue/docs/directives/index.html" class="nav-link"> 指令目录 </a></li>
<li class="nav-item active"><a href="../../../bootstrap-vue/docs/directives/hover.html" class="nav-link"> Hover 指令<small class="badge text-uppercase badge-success">New</small> </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/directives/popover.html" class="nav-link"> Popover 提示备注</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/directives/scrollspy.html" class="nav-link"> Scrollspy 滚动监听</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/directives/tooltip.html" class="nav-link"> Tooltip 提示指令</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/directives/visible.html" class="nav-link"> Visible 可见性操作<small class="badge text-uppercase badge-success">New</small> </a></li>
</ul>
</div>
<div class="bd-toc-item"><a href="../../../bootstrap-vue/docs/icons.html" class="bd-toc-link"> Icons图标</a>
<ul class="nav bd-sidenav">
</ul>
</div>
  
<div class="bd-toc-item"><a class="bd-toc-link" href="../../../bootstrap-vue/docs/reference">参考</a>
<ul class="nav bd-sidenav">
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference" class="nav-link.html"> 参考目录 </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference/accessibility.html" class="nav-link">友好访问</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference/color-variants.html" class="nav-link">Color颜色变量 </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference/images.html" class="nav-link"> 组件图像img的src路径解析</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference/router-links.html" class="nav-link"> Router路由支持 </a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference/size-props.html" class="nav-link">大小规格</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference/spacing-classes.html" class="nav-link">间距处理</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference/starter-templates.html" class="nav-link">开始模板</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference/theming.html" class="nav-link">主题色彩</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference/utility-classes.html" class="nav-link">通用Class类</a></li>
<li class="nav-item"><a href="../../../bootstrap-vue/docs/reference/validation.html" class="nav-link">Form表单验证</a></li>
</ul>
</div>
<div class=""><a href="https://bootstrap-vue.org/play" class="bd-toc-link" target="_blank">在线模拟器</a></div>
</nav>
</div>

<div class="d-none d-xl-block col-xl-2 bd-toc">

<ul class="section-nav">
<li class="nav-item toc-entry mb-2"><a target="_self" href="#form-file-input" class="nav-link font-weight-bold"><span>文件选择(Form File Input)</span></a></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#single-file-default" class="nav-link"><span>单个文件（默认）</span></a> <!----></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#multiple-files" class="nav-link"><span>多个文件</span></a> <!----></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#directory-mode" class="nav-link"><span>目录模式</span></a> <!----></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#drag-and-drop-support" class="nav-link"><span>拖放支持</span></a> <!----></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#limiting-to-certain-file-types" class="nav-link"><span>限制为某些文件类型</span></a> <!----></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#customizing" class="nav-link"><span>自定义</span></a>
<ul class="nav flex-column">
<li class="nav-item toc-entry toc-h3"><a target="_self" href="#control-sizing" class="nav-link"><span>控制尺寸</span></a></li>
<li class="nav-item toc-entry toc-h3"><a target="_self" href="#customize-the-placeholder-text" class="nav-link"><span>自定义占位符文本</span></a></li>
<li class="nav-item toc-entry toc-h3"><a target="_self" href="#customize-browse-button-label" class="nav-link"><span>自定义浏览按钮标签</span></a></li>
<li class="nav-item toc-entry toc-h3"><a target="_self" href="#file-name-formatter-function" class="nav-link"><span>文件名格式化函数</span></a></li>
<li class="nav-item toc-entry toc-h3"><a target="_self" href="#file-name-formatting-via-scoped-slot" class="nav-link"><span>通过作用域插槽格式化文件名</span></a></li>
</ul>
</li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#non-custom-file-input" class="nav-link"><span>非自定义文件输入</span></a> <!----></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#contextual-state-feedback" class="nav-link"><span>上下文状态反馈</span></a> <!----></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#autofocus" class="nav-link"><span>自动获取焦点</span></a> <!----></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#accessibility" class="nav-link"><span>辅助功能</span></a> <!----></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#clearing-the-file-selection" class="nav-link"><span>清除文件选择</span></a> <!----></li>
<li class="nav-item toc-entry toc-h2 mb-1"><a target="_self" href="#component-reference" class="nav-link"><span>组件引用</span></a>
<ul class="nav flex-column">
<li class="nav-item toc-entry toc-h3"><a target="_self" href="#comp-ref-b-form-file" class="nav-link"><span>&lt;b-form-file&gt;</span></a></li>
<li class="nav-item toc-entry toc-h3"><a target="_self" href="#importing-individual-components" class="nav-link"><span>导入单个组件</span></a></li>
<li class="nav-item toc-entry toc-h3"><a target="_self" href="#importing-as-a-plugin" class="nav-link"><span>导入为Vue.js插件</span></a></li>
</ul>
</li>
</ul>
</div>

<main class="col-12 col-md-9 col-xl-8 py-md-3 pl-md-5 bd-content" role="main">

<nav data-v-aafc4aea="" aria-label="Breadcrumbs" class="float-left mt-2 mb-0 mb-lg-2">
<ol data-v-aafc4aea="" class="breadcrumb d-inline-flex bg-transparent px-2 py-1 my-0">
<li data-v-aafc4aea="" class="breadcrumb-item"><a data-v-aafc4aea="" href="../../" class="nuxt-link-active" target="_self">首页</a></li>
<li data-v-aafc4aea="" class="breadcrumb-item"><a data-v-aafc4aea="" href="../../../bootstrap-vue/docs" class="nuxt-link-active" target="_self">中文手册</a></li>
<li data-v-aafc4aea="" class="breadcrumb-item"><a data-v-aafc4aea="" href="../../../bootstrap-vue/docs/components/" class="nuxt-link-active" target="_self">组件</a></li>
<li data-v-aafc4aea="" class="breadcrumb-item active"><span data-v-aafc4aea="" aria-current="location">文件选择</span></li>
</ol>
</nav>
<div class="clearfix d-block"></div>
  <h1 class="bd-title" id="content">文件选择(Form File Input)</h1>
<p class="bd-lead">定制的，跨浏览器一致的文件输入控件，支持单个文件，多个文件和目录上传（对于支持目录模式的浏览器）</p>
  <script type="text/javascript" src="../../../v4/assets/js/pupCMS.js"></script>




<nav class="bd-quick-links mb-3 d-xl-none" data-v-811345e6="">
<header data-v-811345e6="">
<button data-v-811345e6="" type="button" class="btn font-weight-bold btn-outline-secondary btn-sm btn-block collapsed" aria-controls="bd-quick-links-collapse" aria-expanded="false"><span data-v-811345e6="">Show</span> page table of contents </button>
</header>
<ul data-v-811345e6="" id="bd-quick-links-collapse" class="collapse" style="display: none;">
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#single-file-default" class=""><span data-v-811345e6="">Single file (default)</span></a> <!----></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#multiple-files" class=""><span data-v-811345e6="">Multiple files</span></a> <!----></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#directory-mode" class=""><span data-v-811345e6="">Directory mode</span></a> <!----></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#drag-and-drop-support" class=""><span data-v-811345e6="">Drag and Drop support</span></a> <!----></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#limiting-to-certain-file-types" class=""><span data-v-811345e6="">Limiting to certain file types</span></a> <!----></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#customizing" class=""><span data-v-811345e6="">Customizing</span></a>
<ul data-v-811345e6="">
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#control-sizing" class=""><span data-v-811345e6="">Control sizing</span></a></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#customize-the-placeholder-text" class=""><span data-v-811345e6="">Customize the placeholder text</span></a></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#customize-browse-button-label" class=""><span data-v-811345e6="">Customize browse button label</span></a></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#file-name-formatter-function" class=""><span data-v-811345e6="">File name formatter function</span></a></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#file-name-formatting-via-scoped-slot" class=""><span data-v-811345e6="">File name formatting via scoped slot</span></a></li>
</ul>
</li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#non-custom-file-input" class=""><span data-v-811345e6="">Non custom file input</span></a> <!----></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#contextual-state-feedback" class=""><span data-v-811345e6="">Contextual state feedback</span></a> <!----></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#autofocus" class=""><span data-v-811345e6="">Autofocus</span></a> <!----></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#accessibility" class=""><span data-v-811345e6="">Accessibility</span></a> <!----></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#clearing-the-file-selection" class=""><span data-v-811345e6="">Clearing the file selection</span></a> <!----></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#component-reference" class=""><span data-v-811345e6="">Component reference</span></a>
<ul data-v-811345e6="">
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#comp-ref-b-form-file" class=""><span data-v-811345e6="">&lt;b-form-file&gt;</span></a></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#importing-individual-components" class=""><span data-v-811345e6="">Importing individual components</span></a></li>
<li data-v-811345e6=""><a data-v-811345e6="" target="_self" href="#importing-as-a-plugin" class=""><span data-v-811345e6="">Importing as a Vue.js plugin</span></a></li>
</ul>
</li>
</ul>
</nav>
<div translate="translate" class="bd-example vue-example vue-example-b-form-file notranslate">
<div>
<div class="custom-file b-form-file is-invalid" id="__BVID__3716__BV_file_outer_">
<input type="file" class="custom-file-input is-invalid" id="__BVID__3716">
<label data-browse="Browse" class="custom-file-label" for="__BVID__3716">Choose a file or drop it here...</label>
</div>
<div class="mt-3">Selected file: </div>
<input type="file" class="mt-3 form-control-file" id="__BVID__3717">
<div class="mt-3">Selected file: </div>
</div>
</div>
<figure class="highlight"><pre class="hljs html text-monospace p-2 notranslate xml editable" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- Styled --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span>
      <span class="hljs-attr">v-model</span>=<span class="hljs-string">"file"</span>
      <span class="hljs-attr">:state</span>=<span class="hljs-string">"Boolean(file)"</span>
      <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Choose a file or drop it here..."</span>
      <span class="hljs-attr">drop-placeholder</span>=<span class="hljs-string">"Drop file here..."</span>
    &gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"mt-3"</span>&gt;</span>Selected file: {{ file ? file.name : '' }}<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

    <span class="hljs-comment">&lt;!-- Plain mode --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"file2"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"mt-3"</span> <span class="hljs-attr">plain</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"mt-3"</span>&gt;</span>Selected file: {{ file2 ? file2.name : '' }}<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
  <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
    data() {
      <span class="hljs-keyword">return</span> {
        <span class="hljs-attr">file</span>: <span class="hljs-literal">null</span>,
        <span class="hljs-attr">file2</span>: <span class="hljs-literal">null</span>
      }
    }
  }
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></pre></figure>
<p>为了实现跨浏览器的一致性，Form文件默认为Bootstrap定制文件输入，以替换浏览器的默认设置。它们建立在语义和可访问标记之上，因此可以替代默认文件输入。</p>
<h2 id="single-file-default" class="bv-no-focus-ring"><span class="bd-content-title">单个文件（默认）<a class="anchorjs-link" href="#single-file-default" aria-labelledby="single-file-default"></a></span></h2>
<p>在单文件模式下，当未选择任何文件或用户取消“浏览”对话框时，<code translate="no" class="notranslate text-nowrap">v-model</code> 为 <code translate="no" class="notranslate text-nowrap">null</code> 表示未选择文件。选择文件后，返回值将是 JavaScript <a href="https://developer.mozilla.org/en/docs/Web/API/File" target="_blank" rel="noopener"><code translate="no" class="notranslate text-nowrap">File</code></a> 对象实例。</p>
<h2 id="multiple-files" class="bv-no-focus-ring"><span class="bd-content-title">多个文件<a class="anchorjs-link" href="#multiple-files" aria-labelledby="multiple-files"></a></span></h2>
<p>通过向组件添加 <code translate="no" class="notranslate text-nowrap">multiple</code> 属性来支持多个文件上传。在这种情况下，<code translate="no" class="notranslate text-nowrap">v-model</code> <em>始终</em> 是一个 <code translate="no" class="notranslate text-nowrap">Array</code> 。如果未选择任何文件，则将返回一个空数组。当选择一个或多个文件时，返回值将是 JavaScript <a href="https://developer.mozilla.org/en/docs/Web/API/File" target="_blank" rel="noopener"><code translate="no" class="notranslate text-nowrap">File</code></a> 对象实例的数组。</p>
<h2 id="directory-mode" class="bv-no-focus-ring"><span class="bd-content-title">目录模式<a class="anchorjs-link" href="#directory-mode" aria-labelledby="directory-mode"></a></span></h2>
<p>通过添加 <code translate="no" class="notranslate text-nowrap">directory</code>【目录】属性，用户可以选择目录而不是文件。选择目录后，该目录及其整个内容层次结构将包含在所选项目集中。可以使用 <code translate="no" class="notranslate text-nowrap">webkitEntries</code> 属性获取选定的文件系统条目。</p>
<p><strong>注意</strong> 这是一项非标准功能，但最新的 Firefox 和 Chrome 版本支持该功能，因此不应将其用于生产。<a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory" target="_blank" rel="noopener">进一步了解MDN</a> 。</p>
<p>当文件输入为 plain 模式时，不支持目录模式。</p>
<h2 id="drag-and-drop-support" class="bv-no-focus-ring"><span class="bd-content-title">拖放支持<a class="anchorjs-link" href="#drag-and-drop-support" aria-labelledby="drag-and-drop-support"></a></span></h2>
<p>默认情况下，启用丢弃模式。可以通过设置 <code translate="no" class="notranslate text-nowrap">no-drop</code> 属性来禁用它。在 plain 模式下，<code translate="no" class="notranslate text-nowrap">no-drop</code> 无效。</p>
<p>您可以选择通过 <code translate="no" class="notranslate text-nowrap">drop-placeholder</code> 属性设置其他占位符。默认为无放置占位符文本。仅支持纯文本。不支持HTML和组件。如果未设置 <code translate="no" class="notranslate text-nowrap">no-drop</code> 或在 <code translate="no" class="notranslate text-nowrap">plain</code> 模式下，<code translate="no" class="notranslate text-nowrap">drop-placeholder</code> 属性无效。</p>
<h2 id="limiting-to-certain-file-types" class="bv-no-focus-ring"><span class="bd-content-title">限制为某些文件类型<a class="anchorjs-link" href="#limiting-to-certain-file-types" aria-labelledby="limiting-to-certain-file-types"></a></span></h2>
<p>您可以通过将 <code translate="no" class="notranslate text-nowrap">accept</code> 属性设置为包含允许的文件类型的字符串来限制文件类型。要指定多个类型，请用逗号分隔值。</p>
<figure class="highlight"><pre class="hljs html text-monospace p-2 notranslate" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- Accept all image formats by IANA media type wildcard--&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span> <span class="hljs-attr">accept</span>=<span class="hljs-string">"image/*"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>

  <span class="hljs-comment">&lt;!-- Accept specific image formats by IANA type --&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span> <span class="hljs-attr">accept</span>=<span class="hljs-string">"image/jpeg, image/png, image/gif"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>

  <span class="hljs-comment">&lt;!-- Accept specific image formats by extension --&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span> <span class="hljs-attr">accept</span>=<span class="hljs-string">".jpg, .png, .gif"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></pre></figure>
<p>要接受任何文件类型，请将 <code translate="no" class="notranslate text-nowrap">accept</code> 保留为null（默认值）。您可以混合并匹配IANA媒体类型和扩展名。</p>
<p>有关标准媒体类型的完整列表，请参阅 <a href="http://www.iana.org/assignments/media-types/" target="_blank" rel="noopener">IANA Media Types</a>【IANA媒体类型】。</p>
<p><strong>注意：</strong> 并非所有浏览器都支持或尊重文件输入的 <code translate="no" class="notranslate text-nowrap">accept</code> 属性。</p>
<h2 id="customizing" class="bv-no-focus-ring"><span class="bd-content-title">自定义<a class="anchorjs-link" href="#customizing" aria-labelledby="customizing"></a></span></h2>
<p><code translate="no" class="notranslate text-nowrap">&lt;b-form-file&gt;</code> 不在 <a href="#non-custom-file-input" class="font-weight-bold"><code translate="no" class="notranslate text-nowrap">plain</code> mode</a> 下时，提供了几种自定义其外观的功能。</p>
<h3 id="control-sizing" class="bv-no-focus-ring"><span class="bd-content-title">控制尺寸<a class="anchorjs-link" href="#control-sizing" aria-labelledby="control-sizing"></a></span></h3>
<p>使用 <code translate="no" class="notranslate text-nowrap">size</code> 属性控制输入的视觉大小。默认大小被认为是 <code translate="no" class="notranslate text-nowrap">md</code>（中）。可选大小为 <code translate="no" class="notranslate text-nowrap">lg</code>（大）和 <code translate="no" class="notranslate text-nowrap">sm</code>（小）。这些大小与其他窗体控件上可用的大小一致。</p>
<div translate="translate" class="bd-example vue-example vue-example-form-file-sizes notranslate">
<div>
<div role="group" class="form-row form-group" id="__BVID__3719">
<label for="file-small" class="col-sm-2 col-form-label col-form-label-sm" id="__BVID__3719__BV_label_">Small:</label>
<div class="bv-no-focus-ring col">
<div id="file-small__BV_file_outer_" class="custom-file b-form-file b-custom-control-sm">
<input type="file" id="file-small" class="custom-file-input">
<label for="file-small" data-browse="Browse" class="custom-file-label">No file chosen</label>
</div>
<!----><!----><!----></div>
</div>
<div role="group" class="form-row form-group" id="__BVID__3721">
<label for="file-default" class="col-sm-2 col-form-label" id="__BVID__3721__BV_label_">Default:</label>
<div class="bv-no-focus-ring col">
<div id="file-default__BV_file_outer_" class="custom-file b-form-file">
<input type="file" id="file-default" class="custom-file-input">
<label for="file-default" data-browse="Browse" class="custom-file-label">No file chosen</label>
</div>
<!----><!----><!----></div>
</div>
<div role="group" class="form-row form-group" id="__BVID__3723">
<label for="file-large" class="col-sm-2 col-form-label col-form-label-lg" id="__BVID__3723__BV_label_">Large:</label>
<div class="bv-no-focus-ring col">
<div id="file-large__BV_file_outer_" class="custom-file b-form-file b-custom-control-lg">
<input type="file" id="file-large" class="custom-file-input">
<label for="file-large" data-browse="Browse" class="custom-file-label">No file chosen</label>
</div>
<!----><!----><!----></div>
</div>
</div>
</div>
<figure class="highlight"><pre class="hljs html text-monospace p-2 notranslate xml editable" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">b-form-group</span> <span class="hljs-attr">label</span>=<span class="hljs-string">"Small:"</span> <span class="hljs-attr">label-for</span>=<span class="hljs-string">"file-small"</span> <span class="hljs-attr">label-cols-sm</span>=<span class="hljs-string">"2"</span> <span class="hljs-attr">label-size</span>=<span class="hljs-string">"sm"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"file-small"</span> <span class="hljs-attr">size</span>=<span class="hljs-string">"sm"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">b-form-group</span>&gt;</span>

  <span class="hljs-tag">&lt;<span class="hljs-name">b-form-group</span> <span class="hljs-attr">label</span>=<span class="hljs-string">"Default:"</span> <span class="hljs-attr">label-for</span>=<span class="hljs-string">"file-default"</span> <span class="hljs-attr">label-cols-sm</span>=<span class="hljs-string">"2"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"file-default"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">b-form-group</span>&gt;</span>

  <span class="hljs-tag">&lt;<span class="hljs-name">b-form-group</span> <span class="hljs-attr">label</span>=<span class="hljs-string">"Large:"</span> <span class="hljs-attr">label-for</span>=<span class="hljs-string">"file-large"</span> <span class="hljs-attr">label-cols-sm</span>=<span class="hljs-string">"2"</span> <span class="hljs-attr">label-size</span>=<span class="hljs-string">"lg"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"file-large"</span> <span class="hljs-attr">size</span>=<span class="hljs-string">"lg"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">b-form-group</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></pre></figure>
<p><strong>注意：</strong> Bootstrap v4.x 本身不支持自定义文件控件的大小。但是，BootstrapVue 包含自定义 SCSS / CSS，它增加了对自定义文件输入控件的大小的支持。</p>
<h3 id="customize-the-placeholder-text" class="bv-no-focus-ring"><span class="bd-content-title">自定义占位符文本<a class="anchorjs-link" href="#customize-the-placeholder-text" aria-labelledby="customize-the-placeholder-text"></a></span></h3>
<p>使用 <code translate="no" class="notranslate text-nowrap">placeholder</code> 属性更改未选择文件时显示的提示文本。仅支持纯文本。不支持 HTML 和组件。</p>
<h3 id="customize-browse-button-label" class="bv-no-focus-ring"><span class="bd-content-title">自定义浏览按钮标签<a class="anchorjs-link" href="#customize-browse-button-label" aria-labelledby="customize-browse-button-label"></a></span></h3>
<p>如果要全局更改 <code translate="no" class="notranslate text-nowrap">Browse</code> 标签，则可以在全局样式表中添加类似的内容。另外，建议将 <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:lang" target="_blank" rel="noopener">:lang()</a> 用于多语言站点。</p>
<figure class="highlight"><pre class="hljs css text-monospace p-2 notranslate" translate="no"><span class="hljs-selector-class">.custom-file-input</span><span class="hljs-selector-pseudo">:lang(en)</span> ~ <span class="hljs-selector-class">.custom-file-label</span><span class="hljs-selector-pseudo">::after</span> {
  <span class="hljs-attribute">content</span>: <span class="hljs-string">'Browse'</span>;
}</pre></figure>
<p>或者，您可以通过 <code translate="no" class="notranslate text-nowrap">browse-text</code> 属性设置自定义文件浏览按钮文本的内容。注意，仅支持纯文本。不支持 HTML 和组件。</p>
<h3 id="file-name-formatter-function" class="bv-no-focus-ring"><span class="bd-content-title">文件名格式化函数 <a class="anchorjs-link" href="#file-name-formatter-function" aria-labelledby="file-name-formatter-function"></a></span></h3>
<p>将 <code translate="no" class="notranslate text-nowrap">file-name-formatter</code> 属性设置为接受单个参数的函数，该参数是 <a href="https://developer.mozilla.org/en-US/docs/Web/API/File" target="_blank" rel="noopener"><code translate="no" class="notranslate text-nowrap">File</code></a> 对象的数组。该函数应返回单个格式化的字符串（不支持 HTML ）。如果未选择文件，则不会调用格式化程序。</p>
<p>无论是否设置了 <code translate="no" class="notranslate text-nowrap">multiple</code> 属性，格式化程序的参数始终是一个数组。</p>
<div translate="translate" class="bd-example vue-example vue-example-file-formatter-function notranslate">
<div class="custom-file b-form-file" id="__BVID__3726__BV_file_outer_">
<input type="file" multiple="multiple" class="custom-file-input" id="__BVID__3726">
<label data-browse="Browse" class="custom-file-label" for="__BVID__3726">No file chosen</label>
</div>
</div>
<figure class="highlight"><pre class="hljs html text-monospace p-2 notranslate xml editable" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span> <span class="hljs-attr">multiple</span> <span class="hljs-attr">:file-name-formatter</span>=<span class="hljs-string">"formatNames"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
  <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
    <span class="hljs-attr">methods</span>: {
      formatNames(files) {
        <span class="hljs-keyword">if</span> (files.length === <span class="hljs-number">1</span>) {
          <span class="hljs-keyword">return</span> files[<span class="hljs-number">0</span>].name
        } <span class="hljs-keyword">else</span> {
          <span class="hljs-keyword">return</span> <span class="hljs-string">`<span class="hljs-subst">${files.length}</span> files selected`</span>
        }
      }
    }
  }
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></pre></figure>
<h3 id="file-name-formatting-via-scoped-slot" class="bv-no-focus-ring"><span class="bd-content-title">通过作用域插槽格式化文件名<a class="anchorjs-link" href="#file-name-formatting-via-scoped-slot" aria-labelledby="file-name-formatting-via-scoped-slot"></a></span></h3>
<p>或者，您可以使用作用域插槽 <code translate="no" class="notranslate text-nowrap">file-name</code> 来呈现文件名。作用域插槽将具有以下属性：</p>
<div class="table-responsive-sm">
<table class="b-table table table-bordered table-striped bv-docs-table">
<thead class="thead-default">
<tr>
<th>属性</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td><code translate="no" class="notranslate text-nowrap">files</code></td>
<td>Array</td>
<td><code translate="no" class="notranslate text-nowrap">File</code>【文件】对象数组</td>
</tr>
<tr>
<td><code translate="no" class="notranslate text-nowrap">names</code></td>
<td>Array</td>
<td>文件名数组</td>
</tr>
</tbody>
</table>
</div>
<p>不管 <code translate="no" class="notranslate text-nowrap">multiple</code>【多重】属性的设置如何，这两个属性始终都是数组。</p>
<div translate="translate" class="bd-example vue-example vue-example-file-formatter-slot notranslate">
<div class="custom-file b-form-file" id="__BVID__3728__BV_file_outer_">
<input type="file" multiple="multiple" class="custom-file-input" id="__BVID__3728">
<label data-browse="Browse" class="custom-file-label" for="__BVID__3728">No file chosen</label>
</div>
</div>
<figure class="highlight"><pre class="hljs html text-monospace p-2 notranslate xml editable" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span> <span class="hljs-attr">multiple</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">template</span> <span class="hljs-attr">slot</span>=<span class="hljs-string">"file-name"</span> <span class="hljs-attr">slot-scope</span>=<span class="hljs-string">"{ names }"</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">b-badge</span> <span class="hljs-attr">variant</span>=<span class="hljs-string">"dark"</span>&gt;</span>{{ names[0] }}<span class="hljs-tag">&lt;/<span class="hljs-name">b-badge</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">b-badge</span> <span class="hljs-attr">v-if</span>=<span class="hljs-string">"names.length &gt; 1"</span> <span class="hljs-attr">variant</span>=<span class="hljs-string">"dark"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"ml-1"</span>&gt;</span>
       + {{ names.length - 1 }} More files
     <span class="hljs-tag">&lt;/<span class="hljs-name">b-badge</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span></pre></figure>
<p>使用 <code translate="no" class="notranslate text-nowrap">file-name</code> 插槽时，将忽略 <code translate="no" class="notranslate text-nowrap">file-name-formatter</code> 属性。另外，如果没有选择文件，则不会渲染该插槽。</p>
<h2 id="non-custom-file-input" class="bv-no-focus-ring"><span class="bd-content-title">非自定义文件输入<a class="anchorjs-link" href="#non-custom-file-input" aria-labelledby="non-custom-file-input"></a></span></h2>
<p>您可以通过设置 <code translate="no" class="notranslate text-nowrap">plain</code>【纯】属性使 <code translate="no" class="notranslate text-nowrap">&lt;b-form-file&gt;</code> 呈现浏览器本机文件输入。请注意，设置为 <code translate="no" class="notranslate text-nowrap">plain</code> 时，许多自定义表单文件功能均不适用。</p>
<h2 id="contextual-state-feedback" class="bv-no-focus-ring"><span class="bd-content-title">上下文状态反馈<a class="anchorjs-link" href="#contextual-state-feedback" aria-labelledby="contextual-state-feedback"></a></span></h2>
<p>Bootstrap 包括大多数表单控件上 <code translate="no" class="notranslate text-nowrap">valid</code>【有效】和 <code translate="no" class="notranslate text-nowrap">invalid</code>【无效】状态的验证样式。</p>
<p>一般来说，您需要针对特定类型的反馈使用特定状态：</p>
<ul>
<li><code translate="no" class="notranslate text-nowrap">false</code> （表示无效状态）非常适合存在阻塞或必填字段的情况。用户必须正确填写此字段才能提交表单。</li>
<li><code translate="no" class="notranslate text-nowrap">true</code> （表示有效状态）非常适合在整个表单中都进行逐字段验证并希望鼓励用户遍历其余字段的情况。</li>
<li><code translate="no" class="notranslate text-nowrap">null</code> 不显示验证状态（既不有效也不无效）</li>
</ul>
<p>要在 <code translate="no" class="notranslate text-nowrap">&lt;b-form-file&gt;</code> 上应用上下文状态图标之一，请将 <code translate="no" class="notranslate text-nowrap">state</code>【状态】属性设置为 <code translate="no" class="notranslate text-nowrap">false</code>（对于无效），<code translate="no" class="notranslate text-nowrap">true</code>（对于有效）或 <code translate="no" class="notranslate text-nowrap">null</code>（无验证状态）。</p>
<p><strong>注意：</strong> 在按钮模式下，<strong>不</strong> 支持上下文状态。</p>
<h2 id="autofocus" class="bv-no-focus-ring"><span class="bd-content-title">自动获取焦点<a class="anchorjs-link" href="#autofocus" aria-labelledby="autofocus"></a></span></h2>
<p>当将 <code translate="no" class="notranslate text-nowrap">autofocus</code> 【自动对焦】属性设置为 <code translate="no" class="notranslate text-nowrap">&lt;b-form-file&gt;</code> 时，输入将在插入（即 <strong>mounted</strong>【安装】）到文档中时自动对焦，或者在 Vue <code translate="no" class="notranslate text-nowrap">&lt;keep-alive&gt;</code> 组件内部重新激活。 请注意，此属性 <strong>不会</strong> 在输入上设置 <code translate="no" class="notranslate text-nowrap">autofocus</code>【自动对焦】属性，也无法告诉输入何时可见。</p>
<h2 id="accessibility" class="bv-no-focus-ring"><span class="bd-content-title">辅助功能<a class="anchorjs-link" href="#accessibility" aria-labelledby="accessibility"></a></span></h2>
<p>使用 <code translate="no" class="notranslate text-nowrap">&lt;b-form-file&gt;</code> 输入的自定义版本隐藏原始输入时，<strong>强烈建议</strong> 您通过 <code translate="no" class="notranslate text-nowrap">id</code> 属性提供文档唯一的ID字符串。这将自动呈现所需的额外ARIA属性，以提高使用辅助技术的人员的可用性。</p>
<h2 id="clearing-the-file-selection" class="bv-no-focus-ring"><span class="bd-content-title">清除文件选择<a class="anchorjs-link" href="#clearing-the-file-selection" aria-labelledby="clearing-the-file-selection"></a></span></h2>
<p>使用文件类型输入时，通常 <code translate="no" class="notranslate text-nowrap">v-model</code> 是单向的（这意味着您无法预设所选文件）。但是，您可以通过将 <code translate="no" class="notranslate text-nowrap">v-model</code> 设置为 <code translate="no" class="notranslate text-nowrap">null</code>（对于单模式）或空数组 <code translate="no" class="notranslate text-nowrap">[]</code>（对于多目录模式）来清除文件输入的选定文件。</p>
<p>另外，<code translate="no" class="notranslate text-nowrap">&lt;b-form-file&gt;</code> 提供了 <code translate="no" class="notranslate text-nowrap">reset()</code> 方法，可以调用该方法来清除文件输入。要利用 <code translate="no" class="notranslate text-nowrap">reset()</code> 方法，您将需要获取对 <code translate="no" class="notranslate text-nowrap">&lt;b-form-file&gt;</code> 组件的引用。</p>
<div translate="translate" class="bd-example vue-example vue-example-b-form-file-reset notranslate">
<div>
<div class="custom-file b-form-file mb-2" id="__BVID__3730__BV_file_outer_">
<input type="file" class="custom-file-input" id="__BVID__3730">
<label data-browse="Browse" class="custom-file-label" for="__BVID__3730">No file chosen</label>
</div>
<button type="button" class="btn mr-2 btn-secondary">Reset via method</button>
<button type="button" class="btn btn-secondary">Reset via v-model</button>
<p class="mt-2">Selected file: <b></b></p>
</div>
</div>
<figure class="highlight"><pre class="hljs html text-monospace p-2 notranslate xml editable" translate="no"><span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">b-form-file</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"file"</span> <span class="hljs-attr">ref</span>=<span class="hljs-string">"file-input"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"mb-2"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">b-form-file</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">b-button</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">"clearFiles"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"mr-2"</span>&gt;</span>Reset via method<span class="hljs-tag">&lt;/<span class="hljs-name">b-button</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">b-button</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">"file = null"</span>&gt;</span>Reset via v-model<span class="hljs-tag">&lt;/<span class="hljs-name">b-button</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"mt-2"</span>&gt;</span>Selected file: <span class="hljs-tag">&lt;<span class="hljs-name">b</span>&gt;</span>{{ file ? file.name : '' }}<span class="hljs-tag">&lt;/<span class="hljs-name">b</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
  <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
    data() {
      <span class="hljs-keyword">return</span> {
        <span class="hljs-attr">file</span>: <span class="hljs-literal">null</span>
      }
    },
    <span class="hljs-attr">methods</span>: {
      clearFiles() {
        <span class="hljs-keyword">this</span>.$refs[<span class="hljs-string">'file-input'</span>].reset()
      }
    }
  }
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></pre></figure>
<p><strong>实施注意事项：</strong> 实施注意事项：由于并非所有浏览器都允许设置文件输入的值（甚至设置为null或空字符串），因此 <code translate="no" class="notranslate text-nowrap">b-form-input</code> 采用了一种跨浏览器工作的技术，该技术涉及将输入类型更改为 <code translate="no" class="notranslate text-nowrap">null</code> ，然后立即返回键入 <code translate="no" class="notranslate text-nowrap">file</code>【文件】。</p>
<!-- Component reference added automatically from component package.json --> 

<h2 id="component-reference" tabindex="-1" class="bv-no-focus-ring"><span class="bd-content-title">组件引用<a href="../../../bootstrap-vue/docs/components/form-file#component-reference" class="anchorjs-link" aria-labelledby="component-reference" target="_self"></a></span></h2>

<header data-v-866a22e8="" class="row align-items-center">
<div data-v-866a22e8="" class="col-sm-9">
<h3 data-v-866a22e8="" id="comp-ref-b-form-file" tabindex="-1" class="bv-no-focus-ring"><span data-v-866a22e8="" class="bd-content-title"><code data-v-866a22e8="" translate="translate" class="notranslate bigger">&lt;b-form-file&gt;</code><a data-v-866a22e8="" href="../../../bootstrap-vue/docs/components/form-file#comp-ref-b-form-file" class="anchorjs-link" aria-labelledby="comp-ref-b-form-file" target="_self"></a></span></h3>
<!----> <!----></div>
<div data-v-866a22e8="" class="text-sm-right col-sm-3"><a data-v-866a22e8="" rel="noopener" target="_blank" href="https://github.com/bootstrap-vue/bootstrap-vue/tree/dev/src/components/form-file/form-file.js" class="btn btn-outline-secondary btn-sm"> 查看源代码 </a></div>
</header>
<ul data-v-866a22e8="" class="component-ref-mini-toc my-3">
<li data-v-866a22e8=""><a data-v-866a22e8="" href="#comp-ref-b-form-file-aliases"><code data-v-866a22e8="" translate="translate" class="notranslate">&lt;b-form-file&gt;</code> 组件别名 </a></li>
<li data-v-866a22e8=""><a data-v-866a22e8="" href="#comp-ref-b-form-file-props"><code data-v-866a22e8="" translate="translate" class="notranslate">&lt;b-form-file&gt;</code> 属性 </a></li>
<li data-v-866a22e8=""><a data-v-866a22e8="" href="#comp-ref-b-form-file-v-model"><code data-v-866a22e8="" translate="translate" class="notranslate">&lt;b-form-file&gt;</code> v-model </a></li>
<li data-v-866a22e8=""><a data-v-866a22e8="" href="#comp-ref-b-form-file-slots"><code data-v-866a22e8="" translate="translate" class="notranslate">&lt;b-form-file&gt;</code> 插槽 </a></li>
<li data-v-866a22e8=""><a data-v-866a22e8="" href="#comp-ref-b-form-file-events"><code data-v-866a22e8="" translate="translate" class="notranslate">&lt;b-form-file&gt;</code> 事件 </a></li>
<!---->
</ul>
<article data-v-866a22e8="" class="bd-content">
<h4 data-v-866a22e8="" id="comp-ref-b-form-file-aliases" tabindex="-1" class="bv-no-focus-ring mb-3"><span data-v-866a22e8="" class="bd-content-title"> 组件别名 <a data-v-866a22e8="" href="../../../bootstrap-vue/docs/components/form-file#comp-ref-b-form-file-aliases" class="anchorjs-link" aria-labelledby="comp-ref-b-form-file-aliases" target="_self"></a></span></h4>
<p data-v-866a22e8=""><code data-v-866a22e8="" translate="translate" class="notranslate">&lt;b-form-file&gt;</code> 也可以通过以下别名使用：</p>
<ul data-v-866a22e8="">
<li data-v-866a22e8=""><code data-v-866a22e8="" translate="translate" class="notranslate">&lt;b-file&gt;</code></li>
</ul>
<div data-v-866a22e8="" class="alert alert-info">
<p data-v-866a22e8="" class="mb-0 small"> 注意：组件别名仅在导入所有 BootstrapVue 或使用组件组插件时可用。 </p>
</div>
</article>
<article data-v-866a22e8="" class="bd-content">
<h4 data-v-866a22e8="" id="comp-ref-b-form-file-props" tabindex="-1" class="bv-no-focus-ring mb-3"><span data-v-866a22e8="" class="bd-content-title"> 属性 <a data-v-866a22e8="" href="../../../bootstrap-vue/docs/components/form-file#comp-ref-b-form-file-props" class="anchorjs-link" aria-labelledby="comp-ref-b-form-file-props" target="_self"></a></span></h4>
<div data-v-866a22e8="" class="table-responsive-sm">
<table role="table" aria-busy="false" aria-colcount="4" class="table b-table bv-docs-table table-striped" id="__BVID__3637">
<!----><!---->
<thead role="rowgroup" class="">
<!---->
<tr role="row" class="">
<th role="columnheader" scope="col" tabindex="0" aria-colindex="1" aria-sort="none" class="b-table-sort-icon-left">属性<span class="sr-only"> (Click to sort Ascending)</span></th>
<th role="columnheader" scope="col" tabindex="0" aria-colindex="2" class="">类型</th>
<th role="columnheader" scope="col" tabindex="0" aria-colindex="3" class="">默认值</th>
<th role="columnheader" scope="col" tabindex="0" aria-colindex="4" class="">描述</th>
</tr>
</thead>
<tbody role="rowgroup">
<!---->
<tr role="row" data-pk="id" class="" id="__BVID__3637__row_id">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">id</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">String</td>
<td aria-colindex="3" role="cell" class=""></td>
<td aria-colindex="4" role="cell" class="">用于在渲染的内容上设置“id”属性，并用作根据需要生成任何其他元素ID的基础</td>
</tr>
<!----><!---->
<tr role="row" data-pk="name" class="" id="__BVID__3637__row_name">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">name</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">String</td>
<td aria-colindex="3" role="cell" class=""></td>
<td aria-colindex="4" role="cell" class="">设置表单控件上“name”属性的值</td>
</tr>
<!----><!---->
<tr role="row" data-pk="disabled" class="" id="__BVID__3637__row_disabled">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">disabled</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Boolean</td>
<td aria-colindex="3" role="cell" class=""></td>
<td aria-colindex="4" role="cell" class="">设置为“true”时，禁用组件的功能并将其置于禁用状态</td>
</tr>
<!----><!---->
<tr role="row" data-pk="required" class="" id="__BVID__3637__row_required">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">required</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Boolean</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">false</code></td>
<td aria-colindex="4" role="cell" class="">将“required”【必需】属性添加到表单控件</td>
</tr>
<!----><!---->
<tr role="row" data-pk="form" class="" id="__BVID__3637__row_form">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">form</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">String</td>
<td aria-colindex="3" role="cell" class=""></td>
<td aria-colindex="4" role="cell" class="">表单控件所属的表单的ID。在控件上设置“form”属性</td>
</tr>
<!----><!---->
<tr role="row" data-pk="autofocus" class="" id="__BVID__3637__row_autofocus">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">autofocus</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Boolean</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">false</code></td>
<td aria-colindex="4" role="cell" class="">设置为“true”时，尝试在安装控件时自动将其调焦，或者在保持活动状态时将其重新激活。未在控件上设置“autofocus”属性</td>
</tr>
<!----><!---->
<tr role="row" data-pk="state" class="" id="__BVID__3637__row_state">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">state</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Boolean</td>
<td aria-colindex="3" role="cell" class=""></td>
<td aria-colindex="4" role="cell" class="">控制组件的验证状态外观。“true”表示有效，“false”表示无效”，“null”表示无验证状态</td>
</tr>
<!----><!---->
<tr role="row" data-pk="plain" class="" id="__BVID__3637__row_plain">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">plain</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Boolean</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">false</code></td>
<td aria-colindex="4" role="cell" class="">以普通模式而不是自定义样式模式渲染表单控件</td>
</tr>
<!----><!---->
<tr role="row" data-pk="size" class="" id="__BVID__3637__row_size">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">size</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">String</td>
<td aria-colindex="3" role="cell" class=""></td>
<td aria-colindex="4" role="cell" class="">设置组件外观的大小。'sm'，'md'（默认）或'lg'</td>
</tr>
<!----><!---->
<tr role="row" data-pk="value" class="" id="__BVID__3637__row_value">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">value</code> <!----> <!----> <span data-v-866a22e8="" class="badge badge-primary">v-model</span> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">File or Array</td>
<td aria-colindex="3" role="cell" class=""></td>
<td aria-colindex="4" role="cell" class="">文件输入的当前值。 将是单个 File 对象或 File 对象数组（如果设置了多个或目录）。可以设置为null，也可以设置为空数组以重置文件输入</td>
</tr>
<!----><!---->
<tr role="row" data-pk="accept" class="" id="__BVID__3637__row_accept">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">accept</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">String</td>
<td aria-colindex="3" role="cell" class=""></td>
<td aria-colindex="4" role="cell" class="">在文件输入的“accept”属性上设置的值</td>
</tr>
<!----><!---->
<tr role="row" data-pk="capture" class="" id="__BVID__3637__row_capture">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">capture</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Boolean</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">false</code></td>
<td aria-colindex="4" role="cell" class="">设置后，将指示浏览器使用设备的摄像头（如果支持）</td>
</tr>
<!----><!---->
<tr role="row" data-pk="placeholder" class="" id="__BVID__3637__row_placeholder">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">placeholder</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">String</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">'No file chosen'</code></td>
<td aria-colindex="4" role="cell" class="">在表单控件上设置“placeholder”属性值</td>
</tr>
<!----><!---->
<tr role="row" data-pk="browse-text" class="" id="__BVID__3637__row_browse-text">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">browse-text</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">String</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">'Browse'</code></td>
<td aria-colindex="4" role="cell" class="">文件浏览按钮的文本内容</td>
</tr>
<!----><!---->
<tr role="row" data-pk="drop-placeholder" class="" id="__BVID__3637__row_drop-placeholder">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">drop-placeholder</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">String</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">'Drop files here'</code></td>
<td aria-colindex="4" role="cell" class="">拖动文件时显示为占位符的文本</td>
</tr>
<!----><!---->
<tr role="row" data-pk="multiple" class="" id="__BVID__3637__row_multiple">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">multiple</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Boolean</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">false</code></td>
<td aria-colindex="4" role="cell" class="">设置后，将允许选择多个文件。v-model将是一个数组</td>
</tr>
<!----><!---->
<tr role="row" data-pk="directory" class="" id="__BVID__3637__row_directory">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">directory</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Boolean</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">false</code></td>
<td aria-colindex="4" role="cell" class="">启用目录删除模式（在支持目录模式的浏览器上）</td>
</tr>
<!----><!---->
<tr role="row" data-pk="no-traverse" class="" id="__BVID__3637__row_no-traverse">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">no-traverse</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Boolean</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">false</code></td>
<td aria-colindex="4" role="cell" class="">对于目录删除模式：以平面数组形式返回文件</td>
</tr>
<!----><!---->
<tr role="row" data-pk="no-drop" class="" id="__BVID__3637__row_no-drop">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">no-drop</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Boolean</td>
<td aria-colindex="3" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="word-wrap-normal notranslate">false</code></td>
<td aria-colindex="4" role="cell" class="">禁用拖放模式</td>
</tr>
<!----><!---->
<tr role="row" data-pk="file-name-formatter" class="" id="__BVID__3637__row_file-name-formatter">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">file-name-formatter</code> <!----> <!----> <!----> <!----> <!----></td>
<td aria-colindex="2" role="cell" class="">Function</td>
<td aria-colindex="3" role="cell" class=""></td>
<td aria-colindex="4" role="cell" class="">格式化显示文件名的方法。有关详细信息，请参阅文档</td>
</tr>
<!----><!----><!----><!---->
</tbody>
<!---->
</table>
</div>
<!----> <!----></article>
<article data-v-866a22e8="" class="bd-content">
<h4 data-v-866a22e8="" id="comp-ref-b-form-file-v-model" tabindex="-1" class="bv-no-focus-ring mb-3"><span data-v-866a22e8="" class="bd-content-title"> v-model <a data-v-866a22e8="" href="../../../bootstrap-vue/docs/components/form-file#comp-ref-b-form-file-v-model" class="anchorjs-link" aria-labelledby="comp-ref-b-form-file-v-model" target="_self"></a></span></h4>
<div data-v-866a22e8="" class="table-responsive-sm">
<table role="table" aria-busy="false" aria-colcount="2" class="table b-table bv-docs-table table-striped" id="__BVID__3667">
<!----><!---->
<thead role="rowgroup" class="">
<!---->
<tr role="row" class="">
<th role="columnheader" scope="col" aria-colindex="1" class="">属性</th>
<th role="columnheader" scope="col" aria-colindex="2" class="">事件</th>
</tr>
</thead>
<tbody role="rowgroup">
<!---->
<tr role="row" class="">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="notranslate">value</code></td>
<td aria-colindex="2" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="notranslate">input</code></td>
</tr>
<!----><!---->
</tbody>
<!---->
</table>
</div>
</article>
<article data-v-866a22e8="" class="bd-content">
<h4 data-v-866a22e8="" id="comp-ref-b-form-file-slots" tabindex="-1" class="bv-no-focus-ring mb-3"><span data-v-866a22e8="" class="bd-content-title"> 插槽 <a data-v-866a22e8="" href="../../../bootstrap-vue/docs/components/form-file#comp-ref-b-form-file-slots" class="anchorjs-link" aria-labelledby="comp-ref-b-form-file-slots" target="_self"></a></span></h4>
<div data-v-866a22e8="" class="table-responsive-sm">
<table role="table" aria-busy="false" aria-colcount="3" class="table b-table bv-docs-table table-striped" id="__BVID__3676">
<!----><!---->
<thead role="rowgroup" class="">
<!---->
<tr role="row" class="">
<th role="columnheader" scope="col" aria-colindex="1" class="">插槽名称</th>
<th role="columnheader" scope="col" aria-colindex="2" class="">描述</th>
<th role="columnheader" scope="col" aria-colindex="3" class="">范围</th>
</tr>
</thead>
<tbody role="rowgroup">
<!---->
<tr role="row" data-pk="file-name" class="" id="__BVID__3676__row_file-name">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="text-nowrap notranslate">file-name</code> <!----></td>
<td aria-colindex="2" role="cell" class="">用于格式化文件名的作用域插槽</td>
<td aria-colindex="3" role="cell" class=""><button data-v-866a22e8="" type="button" class="btn py-0 btn-info btn-sm"> Scope </button></td>
</tr>
<!----><!----><!----><!---->
</tbody>
<!---->
</table>
</div>
</article>
<article data-v-866a22e8="" class="bd-content">
<h4 data-v-866a22e8="" id="comp-ref-b-form-file-events" tabindex="-1" class="bv-no-focus-ring mb-3"><span data-v-866a22e8="" class="bd-content-title"> 事件 <a data-v-866a22e8="" href="../../../bootstrap-vue/docs/components/form-file#comp-ref-b-form-file-events" class="anchorjs-link" aria-labelledby="comp-ref-b-form-file-events" target="_self"></a></span></h4>
<div data-v-866a22e8="" class="table-responsive-sm">
<table role="table" aria-busy="false" aria-colcount="3" class="table b-table bv-docs-table table-striped" id="__BVID__3686">
<!----><!---->
<thead role="rowgroup" class="">
<!---->
<tr role="row" class="">
<th role="columnheader" scope="col" aria-colindex="1" class="">事件</th>
<th role="columnheader" scope="col" aria-colindex="2" class="">参数</th>
<th role="columnheader" scope="col" aria-colindex="3" class="">描述</th>
</tr>
</thead>
<tbody role="rowgroup">
<!---->
<tr role="row" data-pk="change" class="" id="__BVID__3686__row_change">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="notranslate">change</code> <!----></td>
<td aria-colindex="2" role="cell" class=""><ol data-v-866a22e8="" class="list-unstyled mb-0">
<li data-v-866a22e8=""><code data-v-866a22e8="" translate="translate" class="notranslate">event</code> - <span data-v-866a22e8="">本机变更事件对象</span></li>
</ol></td>
<td aria-colindex="3" role="cell" class="">输入时的原始本机更改事件</td>
</tr>
<tr role="row" data-pk="input" class="" id="__BVID__3686__row_input">
<td aria-colindex="1" role="cell" class=""><code data-v-866a22e8="" translate="translate" class="notranslate">input</code> <!----></td>
<td aria-colindex="2" role="cell" class=""><ol data-v-866a22e8="" class="list-unstyled mb-0">
<li data-v-866a22e8=""><code data-v-866a22e8="" translate="translate" class="notranslate">file</code> - <span data-v-866a22e8="">在单一模式下将是单个 File 对象，或者在多种模式下将是 File 对象的数组</span></li>
</ol></td>
<td aria-colindex="3" role="cell" class="">更新 v-model 值（有关更多详细信息，请参阅文档）</td>
</tr>
<!----><!---->
</tbody>
<!---->
</table>
</div>
</article>

<article class="bd-content">
<h3 id="importing-individual-components" tabindex="-1" class="bv-no-focus-ring"><span class="bd-content-title"> 导入单个组件 <a href="../../../bootstrap-vue/docs/components/form-file#importing-individual-components" class="anchorjs-link" aria-labelledby="importing-individual-components" target="_self"></a></span></h3>
<p> 您可以通过以下命名的导出将单个组件导入到项目中： </p>
<div class="table-responsive-sm">
<table role="table" aria-busy="false" aria-colcount="3" class="table b-table bv-docs-table table-striped" id="__BVID__3698">
<!----><!---->
<thead role="rowgroup" class="thead-default">
<!---->
<tr role="row" class="">
<th role="columnheader" scope="col" aria-colindex="1" class="">组件</th>
<th role="columnheader" scope="col" aria-colindex="2" class="">命名输出</th>
<th role="columnheader" scope="col" aria-colindex="3" class="">导入路径</th>
</tr>
</thead>
<tbody role="rowgroup">
<!---->
<tr role="row" class="">
<td aria-colindex="1" role="cell" class=""><code translate="translate" class="text-nowrap notranslate">&lt;b-form-file&gt;</code></td>
<td aria-colindex="2" role="cell" class=""><code translate="translate" class="text-nowrap notranslate">BFormFile</code></td>
<td aria-colindex="3" role="cell" class=""><code translate="translate" class="text-nowrap notranslate">bootstrap-vue</code></td>
</tr>
<!----><!---->
</tbody>
<!---->
</table>
</div>
<p><strong>示例：</strong></p>
<figure class="highlight"><pre translate="translate" class="hljs language-js text-monospace p-2 notranslate javascript"><span class="hljs-keyword">import</span> { BFormFile } <span class="hljs-keyword">from</span> <span class="hljs-string">'bootstrap-vue'</span>
Vue.component(<span class="hljs-string">'b-form-file'</span>, BFormFile)</pre></figure>
</article>
<!---->
<article class="bd-content">
<h3 id="importing-as-a-plugin" tabindex="-1" class="bv-no-focus-ring"><span class="bd-content-title"> 导入为Vue.js插件 <a href="../../../bootstrap-vue/docs/components/form-file#importing-as-a-plugin" class="anchorjs-link" aria-labelledby="importing-as-a-plugin" target="_self"></a></span></h3>
<p> 该插件包括上面列出的所有单个组件。插件还包括任何组件别名。 </p>
<div class="table-responsive-sm">
<table fileds="namedExport,importPath" role="table" aria-busy="false" aria-colcount="2" class="table b-table bv-docs-table table-striped b-table-caption-top" id="__BVID__3708">
<!----><!---->
<thead role="rowgroup" class="thead-default">
<!---->
<tr role="row" class="">
<th role="columnheader" scope="col" aria-colindex="1" class="">命名输出</th>
<th role="columnheader" scope="col" aria-colindex="2" class="">导入路径</th>
</tr>
</thead>
<tbody role="rowgroup">
<!---->
<tr role="row" class="">
<td aria-colindex="1" role="cell" class=""><code translate="translate" class="text-nowrap notranslate">FormFilePlugin</code></td>
<td aria-colindex="2" role="cell" class=""><code translate="translate" class="text-nowrap notranslate">bootstrap-vue</code></td>
</tr>
<!----><!---->
</tbody>
<!---->
</table>
</div>
<!---->
<p><strong>示例：</strong></p>
<figure class="highlight"><pre translate="translate" class="hljs language-js text-monospace p-2 notranslate javascript"><span class="hljs-keyword">import</span> { FormFilePlugin } <span class="hljs-keyword">from</span> <span class="hljs-string">'bootstrap-vue'</span>
Vue.use(FormFilePlugin)</pre></figure>
</article>














</main>
</div>
</div>


<script src="../../../v4/assets/js/vendor/jquery-slim.min.js"></script>
<script src="../../../v4/dist/js/popper.min.js"></script> 
<script src="../../../v4/dist/js/bootstrap.min.js"></script> 
<script src="../../../v4/assets/js/docs.min.js"></script> 
<script src="../../../v4/assets/js/ie-emulation-modes-warning.js"></script> 
<script src="../../../v4/assets/js/docsearch.min.js"></script> 
<script>
  docsearch({
    appId: 'PRR89ISST8',
    apiKey: '95044d57d4d7bb744f322d1f18ed607f',
    indexName: 'z01-bootstrapV4',
    inputSelector: '#search-input',
    handleSelected: function (input, event, suggestion) {
      var url = suggestion.url;
      url = suggestion.isLvl1 ? url.split('#')[0]: url;
      // If it's a title we remove the anchor so it does not jump.
      window.location.href = url;
    },
    transformData: function (hits) {
      return hits.map(function (hit) {
        hit.url = hit.url.replace('https://v4-alpha.getbootstrap.com', '/docs/4.0');
        return hit;
      });
    },
    debug: false // Set debug to true if you want to inspect the dropdown
  });
</script> 
<script>
  Holder.addTheme('gray', {
    bg: '#777',
    fg: 'rgba(255,255,255,.75)',
    font: 'Helvetica',
    fontweight: 'normal'
  });
</script>
</body>
</html>
